//查询接口数据
function chaxun(){
   var xmlhttp;
   if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera,Safari
      xmlhttp=new XMLHttpRequest();
   }else{// code for IE6, IE5
      xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
   }
   // xmlhttp.onreadystatechange= function(){
   //    if (xmlhttp.readyState ==4 && xmlhttp.status == 200) {
   //       var expertinfolist = xmlhttp.responseText;
   //       var x=xmlDoc.getElementsByTagName("datas");
   //       var txt="";
   //          for (i=0;i<x.length;i++) {
   //             txt=txt+ x[i].childNodes[0].nodeValue + "<br />"
   //          }
   //       // document.getElementById("tbmain").innerHTML=expertinfolist;
   //      // document.getElementById("tbmain").innerHTML=txt;

   //    }
   // }
   var MSCODE = document.getElementById('strMSCODE').value;
   var MATERIALCODE = document.getElementById('strMATERIALCODE').value;
   
   alert("物料编号："+MATERIALCODE+"看板编号："+MSCODE);//test
   var url="http://cx.ytsps.com:83/webservice/work_service.asmx/LoadKBStateList?strMATERIALCODE="+MATERIALCODE+"&strMSCODE="+MSCODE;
   xmlhttp.open("GET", url,true);
   xmlhttp.send();


//模拟一段数据

   //模拟数据
   cache:false
   var datas = [
             {id:'1017026811',name:'9842513401',job:'已发货',zhuangt:'2019/8/31 18:56:19',date:'沪BS4896'},
            // {id:'660011763001742',name:'9842495901',job:'备货中',zhuangt:'',date:''},
            // {id:'660011035601742',name:'9842471901',job:'已发货',zhuangt:'2019/8/31 18:18:42',date:'沪DL8189'}
            //{|660011035601742|9842471901|沪DL8189|已发货|2019/8/31 18:18:42}
         ];
   //整理数据
     var tbody = document.getElementById('tbMain');
     for(var i = 0;i < datas.length; i++){ //遍历一下json数据
        $("#tbMain").empty();//清楚上次的查询记录

        var trow = getDataRow(datas[i]); //定义一个方法,返回tr数据
        tbody.appendChild(trow);
      }
      
         function getDataRow(h){
          var row = document.createElement('tr'); //创建行
          
          var idCell = document.createElement('td'); //创建第一列id
          idCell.innerHTML = h.id; //填充数据
          row.appendChild(idCell); //加入行  ，下面类似
          
          var nameCell = document.createElement('td');//创建第二列name
          nameCell.innerHTML = h.name;
          row.appendChild(nameCell);
          
          var jobCell = document.createElement('td');//创建第三列job
          jobCell.innerHTML = h.job;
          row.appendChild(jobCell);

          var zhuangtCell = document.createElement('td');//创建第四列zhuangt
          zhuangtCell.innerHTML = h.zhuangt;
          row.appendChild(zhuangtCell);
          
          var dateCell = document.createElement('td');//创建第五列date
          dateCell.innerHTML = h.date;
          row.appendChild(dateCell);
          
          //到这里，json中的数据已经添加到表格中
          
          return row; //返回tr数据    
          }

 };

// 表格左右滑动
var oBox = $('.box');
var oBoxWidth = $('.box').width();
var oBoxHeight = $('.box').height();

oBox.find('div').on('click',function(){
var thisWidth = $(this).width();
var moveLeft = this.offsetLeft;
   if(oBoxWidth<moveLeft+thisWidth){
          oBox.animate({scrollLeft:moveLeft});
   }else{
          oBox.animate({scrollLeft:0});   
   }
});



//禁用PC端右键,调试时暂时关闭
// document.oncontextmenu=new Function("return false")
// document.onselectstart=new Function("return false")


// // 对浏览器的UserAgent进行正则匹配，不含有微信独有标识的则为其他浏览器（只允许微信访问）
// var useragent = navigator.userAgent;
//    if(useragent.match(/WindowsWechat/) == 'WindowsWechat' || useragent.match(/MicroMessenger/i) != 'MicroMessenger') {
//    // 这里警告框会阻塞当前页面继续加载
//    //alert('已禁止本次访问：您必须使用微信内置浏览器访问本页面！');
//       document.head.innerHTML = '<title>抱歉，出错了</title><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=0"><link rel="stylesheet" type="text/css" href="https://res.wx.qq.com/open/libs/weui/0.4.1/weui.css">';
//       document.body.innerHTML = '<div class="weui_msg"><div class="weui_icon_area"><i class="weui_icon_info weui_icon_msg"></i></div><div class="weui_text_area"><h4 class="weui_msg_title">请在微信客户端打开链接</h4></div></div>';
//    }



//test
// function chaxun() {          
// //这是我们在第一步中创建的Web服务的地址          
// var URL = "http://cx.ytsps.com:83/webservice/work_service.asmx/LoadKBStateList";         
// //在这处我们拼接          
// var data;          
// data = '<?xml version="1.0" encoding="utf-8"?>';   
// data = data + '<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">';         
// data = data + '<soap:Body>';    
// data = data + '<LoadKBStateListResponse xmlns="http://API.YTLPS.com/">';
// data = data + '<LoadKBStateListResult>string</LoadKBStateListResult>';   
// data = data + '</LoadKBStateListResponse>';   
// data = data + '</soap:Body>';           
// data = data + '</soap:Envelope>';

// //创建异步对象
// var xmlhttp;
//    if (window.XMLHttpRequest){// code for IE7+, Firefox, Chrome, Opera,Safari
//       xmlhttp=new XMLHttpRequest();
//    }else{// code for IE6, IE5
//       xmlhttp= new ActiveXObject("Microsoft.XMLHTTP");
//    }
//    var MATERIALCODE = document.getElementById('strMATERIALCODE').value;
//    var MSCODE = document.getElementById('strMSCODE').value;
//    alert("输入的内容："+MATERIALCODE+"."+MSCODE);//test
//    var url="http://cx.ytsps.com:83/webservice/work_service.asmx/LoadKBStateList?strMATERIALCODE="+MATERIALCODE+"&strMSCODE="+MSCODE;       
// // xmlhttp.Open("POST", URL, false);
// xmlhttp.open("GET", url,true);
// xmlhttp.setRequestHeader("Content-Type", "application/soap+xml");
// xmlhttp.send(data);
// //document.getElementById("data").innerHTML = xmlhttp.responseText;
// }  
